#!C:\Perl\bin\perl.exe
# amazon_http.pl
# A typical Amazon Web API Perl script using the XML/HTTP interface
# Usage: amazon_http.pl <keyword> 

#Your Amazon developer's token
my $dev_key='insert developer token';

#Your Amazon affiliate code
my $af_tag='insert associate tag';

#Take the keyword from the command-line
my $keyword =shift @ARGV or die "Usage:perl amazon_http.pl <keyword>\n";

#Assemble the URL
my $url = "http://xml.amazon.com/onca/xml3?t=" . $af_tag . 
    "&dev-t=" . $dev_key .
    "&type=lite&f=xml&mode=books&" .
    "KeywordSearch=" . $keyword;

use strict;

#Use the XML::Parser  and LWP::Simple Perl modules
use XML::Simple;
use LWP::Simple;

my $content = get($url);
die "Could not retrieve $url" unless $content;

my $xmlsimple = XML::Simple->new(  );
my $response = $xmlsimple->XMLin($content);

foreach my $result (@{$response->{Details}}){
    #Print out the main bits of each result
    print
    join "\n",
    $result->{ProductName}||"no title",
    "ASIN: " . $result->{Asin} . ", " .
    $result->{OurPrice} . "\n\n";
}